package cate.game.play.skill.passive.fairy;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.AppendMove;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 效果1：“秽土转生”非复活治疗系数+24%,如场上存在可复活目标则无视控制释放该技能
 * 效果2：“荒漠之花”释放后50%概率随机清除1个负面状态，并有35%概率再次释放
 */
public class 咖喱咖喱灵器PH extends PassiveHandler {

	private String 秽土转生标签;

	private String 荒漠之花标签;

	private int 概率;

	private double 血量调整;

	//秽土转生标签=秽土转生&
	//荒漠之花标签=荒漠之花&概率=3500&血量调整=-5000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		秽土转生标签 = args.get("技能标签");
		荒漠之花标签 = args.get("荒漠之花标签");
		概率 = args.getInt("概率", 0);
		血量调整 = args.getWDouble("血量调整", -5000d);
	}

	@Override
	public void beforeOwnerMove(MoveCtx move, TimeActionCtx action) {
		if (!move.skill.cfg.containTag(秽土转生标签)) {
			return;
		}
		for (Fighter friend : skill.owner.getFightTeam().getFriends(skill.owner)) {
			if (friend.isDead()) {
				move.getSkill().param.setIgnCtrlMove(true);
				return;
			}
		}
	}

	@Override
	public void onOwnerMoveDone(MoveCtx move, TimeActionCtx action) {
		if (move.isAppend()) {
			return;
		}
		if (!move.getSkill().cfg.containTag(荒漠之花标签)) {
			return;
		}
		if (!XT.chance(概率)) {
			return;
		}
		AppendMove append = new AppendMove(skill.owner, move.skill);
		append.hpChangeRate = 血量调整;
		move.getTurn().addAppend(append);
	}
}
